﻿using System;

namespace Agile.DataAccess
{
    /// <summary>
    /// 
    /// </summary>
    public interface IDbProvider
    {
        /// <summary>
        /// 
        /// </summary>
        string ProviderName { get; }
        /// <summary>
        /// 
        /// </summary>
        bool SupportsMultipleResultsets { get; }
        /// <summary>
        /// 
        /// </summary>
        bool SupportsMultipleQueries { get; }
        /// <summary>
        /// 
        /// </summary>
        bool SupportsOutputParameters { get; }
        /// <summary>
        /// 
        /// </summary>
        bool SupportsStoredProcedures { get; }
        /// <summary>
        /// 
        /// </summary>
        bool RequiresIdentityColumn { get; }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parameterName"></param>
        /// <returns></returns>
        string GetParameterName(string parameterName);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <param name="alias"></param>
        /// <returns></returns>
        string GetSelectBuilderAlias(string name, string alias);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        string GetSqlForQueryBuilder(QueryBuilderData data);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <param name="isBuilder"></param>
        /// <returns></returns>
        string GetSqlForSelectBuilder(SelectBuilderData data, bool isBuilder);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        string GetSqlForInsertBuilder(BuilderData data);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        string GetSqlForUpdateBuilder(BuilderData data);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        string GetSqlForDeleteBuilder(BuilderData data);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        string GetSqlForExistsBuilder(BuilderData data);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        string GetSqlForStoredProcedureBuilder(BuilderData data);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <param name="orderBy"></param>
        /// <returns></returns>
        string GetSqlForPagingBuilder(SelectBuilderData data, string orderBy = null);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="clrType"></param>
        /// <returns></returns>
        DataTypes GetDbTypeForClrType(Type clrType);
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="command"></param>
        /// <param name="identityColumnName"></param>
        /// <returns></returns>
        object ExecuteReturnLastId<T>(IDbCommand command, string identityColumnName);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        void OnCommandExecuting(IDbCommand command);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        string EscapeColumnName(string name);
    }
}
